package Interfaz;

import Controladores.*;
import Interfaz.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Adrian
 */
public class VentanaEliminarMesa extends Ventana_Defaults {

    /**
     * Creates new form Reservaciones
     */
    Mesa mesa;
    ResultSet rs;
    public VentanaEliminarMesa() {
        try {
            initComponents();
            mesa = new Mesa();
            setSize(550, 300);
            setLocationRelativeTo(null);
            setResizable(false);
            setTitle("Agregar Mesa");
            rs = mesa.listarMesas();
            while(rs.next()){
                cmbMesas.addItem(rs.getString("idMesa"));
            }
        } catch (SQLException ex) {
            Logger.getLogger(VentanaEliminarMesa.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnAgregarMesa = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        btnAtras1 = new javax.swing.JButton();
        cmbMesas = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setAlwaysOnTop(true);
        getContentPane().setLayout(null);

        btnAgregarMesa.setFont(new java.awt.Font("AR CENA", 0, 18)); // NOI18N
        btnAgregarMesa.setText("Eliminar");
        btnAgregarMesa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarMesaActionPerformed(evt);
            }
        });
        getContentPane().add(btnAgregarMesa);
        btnAgregarMesa.setBounds(290, 150, 120, 33);

        jLabel1.setFont(new java.awt.Font("AR CENA", 0, 18)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Numero de Mesa");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(60, 60, 140, 24);

        btnAtras1.setFont(new java.awt.Font("AR CENA", 0, 14)); // NOI18N
        btnAtras1.setText("Atras");
        btnAtras1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAtras1ActionPerformed(evt);
            }
        });
        getContentPane().add(btnAtras1);
        btnAtras1.setBounds(20, 20, 73, 23);
        getContentPane().add(cmbMesas);
        cmbMesas.setBounds(220, 60, 120, 20);

        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/interior.jpg"))); // NOI18N
        getContentPane().add(jLabel4);
        jLabel4.setBounds(-30, -40, 570, 290);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnAtras1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAtras1ActionPerformed
        this.dispose();
    }//GEN-LAST:event_btnAtras1ActionPerformed

    private void btnAgregarMesaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarMesaActionPerformed
        mesa.eliminarMesa(cmbMesas.getSelectedItem().toString());
        JOptionPane.showMessageDialog(this, "Mesa eliminada exitosamente");
    
        this.dispose();
    }//GEN-LAST:event_btnAgregarMesaActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(VentanaEliminarMesa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(VentanaEliminarMesa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(VentanaEliminarMesa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(VentanaEliminarMesa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VentanaEliminarMesa().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAgregarMesa;
    private javax.swing.JButton btnAtras1;
    private javax.swing.JComboBox cmbMesas;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel4;
    // End of variables declaration//GEN-END:variables
}
